package com.zrwl.poscloud.core.restapi.mobile;

import com.zrwl.poscloud.commons.exception.ThrowableUtils;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.validator.group.GetList;
import com.zrwl.poscloud.core.annotion.AuthorityVerify.AuthorityVerify;
import com.zrwl.poscloud.xo.service.UserServiceConfigDetailService;
import com.zrwl.poscloud.xo.service.UserServiceConfigService;
import com.zrwl.poscloud.xo.vo.UserServiceConfigDetailVO;
import com.zrwl.poscloud.xo.vo.UserServiceConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 产品配置 controller api类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-05-23
 */
@RestController
@Api(value = "产品配置相关接口", tags = {"产品配置相关接口"})
@RequestMapping("/serviceConfig")
@Slf4j
public class ServiceConfigRestApi {
    @Autowired
    private UserServiceConfigService userServiceConfigService;
    @Autowired
    private UserServiceConfigDetailService userServiceConfigDetailService;
    @AuthorityVerify
    @ApiOperation(value = "获取产品配置列表", notes = "获取产品配置列表", response = String.class)
    @PostMapping("/getServiceConfigList")
    public String getServiceConfigList(@Validated({GetList.class}) @RequestBody UserServiceConfigVO userServiceConfigVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取产品配置列表: {}", userServiceConfigVO);
        return ResultUtil.successWithData(userServiceConfigService.getServiceConfigList(userServiceConfigVO));
    }
    @AuthorityVerify
    @ApiOperation(value = "获取产品配置明细", notes = "获取产品配置明细", response = String.class)
    @PostMapping("/getServiceConfigDetailInfo")
    public String getServiceConfigDetailInfo(@Validated({GetList.class}) @RequestBody UserServiceConfigDetailVO userServiceConfigDetailVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取产品配置列表: {}", userServiceConfigDetailVO);
        return ResultUtil.successWithData(userServiceConfigDetailService.getServiceConfigDetailInfo(userServiceConfigDetailVO));
    }
}
